#include <iostream>
#include "basic/basic.h"
#include "thread/blocked_thread.hpp"
#include "thread/auto_thread.hpp"
#include "thread/scoped_thread.hpp"
#include "thread/thread.h"

void testAutoThread(){
	boost::this_thread::sleep(boost::posix_time::seconds(rand() % 5));
	std::cout << "testAutoThread " << time(NULL) << std::endl;
}
void testScopedThread(){
	boost::this_thread::sleep(boost::posix_time::seconds(rand() % 20));
	std::cout << "testScopedThread " << time(NULL) << std::endl;
}
void testBlockedThread(){
	boost::this_thread::sleep(boost::posix_time::seconds(rand() % 10));
	std::cout << "testBlockedThread " << time(NULL) << std::endl;
}
class testAsyncTask{
public:
	void test(int num){
		boost::this_thread::sleep(boost::posix_time::milliseconds(rand() % 100));
		std::cout << "testAsyncTask::test num:" << num << ",th:" << boost::this_thread::get_id() << std::endl;
	}
};


int main() {
	{	// 测试线程
		std::cout << "Enter test thread" << std::endl;
		getchar();

		eyas::thread::blocked_thread blockedThread(&testBlockedThread);
		eyas::thread::auto_thread autoThread(&testAutoThread);
		eyas::thread::scoped_thread scopedThread(&testScopedThread);
	}
	std::cout << "Enter exit the test." << std::endl;
	getchar();
	return 0;
}
